---
title: "Table A.5"
output: 
---

# Table A.5

# Who's to Blame? Postconflict Violence and Public Attitudes Towards Peace Agreements
# Wyer, Frank. 

#clear environment
```{r clear environment}
rm(list = ls())
```

# uncomment and set working directory to replication archive
# setwd("~/blame_replication")

# Uncomment to install packages if necessary
# install.packages("tidyverse")
# install.packages("texreg")
# install.packages("estimatr")


#load packages
```{r}
library(tidyverse)
library(estimatr)
library(texreg)
```

#read in data
```{r}
survey_clean <- read.csv("survey_clean.csv")
```

#treatment variable factor with government culpability treatment (T2A) as baseline
```{r new treatment with T2A as baseline}
#create treatment variable with T1 as reference instead of control 
survey_clean$treatment_vsT2A <- as.factor(survey_clean$treatment)
survey_clean$treatment_vsT2A <- relevel(survey_clean$treatment_vsT2A, ref = "T2A")
```

#use lin estimator for each outcome with the releveled treatment variable
```{r estimate models with releveled treatment}
eln_t2avst2b <- lm_lin(formula = eln_scale ~ treatment_vsT2A, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)

accords_t2avst2b <- lm_lin(formula = accords_scale ~ treatment_vsT2A, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)

dissident_t2avst2b <- lm_lin(dissident_scale ~ treatment_vsT2A, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)

index_t2avst2b <- lm_lin(outcomes_zscale ~ treatment_vsT2A, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)
```

#generate table
```{r texreg table}
texreg(list(accords_t2avst2b, eln_t2avst2b, dissident_t2avst2b, index_t2avst2b), custom.coef.map = list("(Intercept)" = "(Intercept)",  "treatment_vsT2AT2B" = "Rebel Culpability Treatment"), digits = 2, include.ci = FALSE, single.row = FALSE, include.fstatistic = FALSE, include.rmse = FALSE, include.rsquared = FALSE, include.adjrs = FALSE, include.nobs = TRUE, stars = numeric(0), float.pos = "h", caption.above	= TRUE, caption = "Treatment Effects: Rebel Culpability Treatment vs Government Culpability Treatment")
```